<?php
include('../config.php');
include(PUNG_ROOT . '/admin/header.php');
include(PUNG_ROOT . '/system/class/gd.class.php');

$adminmenu = array(
LANG_091 => 'blocks.php',
LANG_092 => 'addblock.php',
LANG_112 => 'editblock.php'
);

if(!is_numeric($_GET['id']))
{
	redirect_with_message('msg', 'LANG_118', 'blocks.php');
}

if(isset($_POST['submit']))
{
	$db -> db_query("UPDATE " . DB_PREFIX . "blocks SET
	title = '" . addslashes($_POST['title']) . "',
	content = '" . addslashes($_POST['content']) . "',
	type = '" . $_POST['type'] . "' 
	WHERE id = '" . $_GET['id'] . "'");
	
	redirect_with_message('msg', 'LANG_119', 'blocks.php');
}

include(PUNG_ROOT . '/admin/head.php');
?>

<h3><?php print LANG_112; ?></h3>

<?php
$id = $_GET['id'];
$sql = $db -> db_query("SELECT * FROM " . DB_PREFIX . "blocks 
WHERE id = '$id' LIMIT 1");
$sql = $db -> db_result();
?>

<form action="" method="post">
<table width="100%">
<tr>
	<td width="120"><strong><?php print LANG_113; ?>:</strong></td>
	<td><input type="text" style="width: 350px;" value="<?php print $sql['0']['title']; ?>" name="title" /></td>
</tr>
<tr>
	<td valign="top"><strong><?php print LANG_114; ?>:</strong></td>
	<td>
	<?php if($sql['0']['type'] == 'php'){print '<span style="color:red; font-weight:bold">&lt;?php</span><br />';} ?>
	<textarea style="width: 350px; height: 200px" 
	name="content"><?php print stripslashes($sql['0']['content']); ?></textarea>
	<?php if($sql['0']['type'] == 'php'){print '<br /><span style="color:red; font-weight:bold">?&gt;</span>';} ?>
	</td>
</tr>
<tr>
	<td valign="top"><strong><?php print LANG_115; ?>:</strong></td>
	<td>
	<input type="radio" value="plain" name="type"<?php if($sql['0']['type'] == 'plain'){print ' checked="checked"';} ?> /> <?php print LANG_117; ?><br />
	<input type="radio" value="php" name="type"<?php if($sql['0']['type'] == 'php'){print ' checked="checked"';} ?> /> <?php print LANG_116; ?>
	</td>
</tr>
</table>
<br />
<input type="submit" name="submit" class="form_button" value="<?php print LANG_105; ?>" />
</form>

<?php
include(PUNG_ROOT . '/admin/footer.php');
?>